<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0 auto;
        }
        .box{
            width: 400px;
            height: 400px;
            background-color: pink;
            text-align: center;
            font-size: larger;
        }
    </style>
</head>
<body>
    <div class="box">当窗口大小小于800时,就消失</div>
    <script>
        var box = document.querySelector('.box');
        window.addEventListener('resize', function() {
            if (window.innerWidth < 800) {
                box.style.display = 'none';
            }else {
                box.style.display = 'block';
            }
        })
    </script>
</body>
</html>